import logging

from redis import StrictRedis


class Config(object):
    """项目配置"""
    DEBUG = True

    """mysql数据库配置"""
    SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://root:root@127.0.0.1/infomation01"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    """redis 数据库配置"""
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    """session设置"""
    # session加密key
    SECRET_KEY = "itcast"
    # session保存到redis中
    SESSION_TYPE = "redis"
    # 指定redis
    SESSION_REDIS = StrictRedis(REDIS_HOST, REDIS_PORT)
    # 设置签名
    SESSION_USE_SIGNER = True
    # 设置非永久性
    SESSION_PERMANENT = False
    # 设置存储有效期
    PERMANENT_SESSION_LIFETIME = 60 * 60 * 24

    """设置日志等级"""
    LOG_LEVEL = logging.DEBUG


class DevConfig(Config):
    DEBUG = True


class ProConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


config = {
    "dev": DevConfig,
    "pro": ProConfig
}
